﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentValidation;
using Microhard.NotificationTypes.Models;
using FluentValidation.Results;

namespace Microhard.NotificationTypes.Validator
{
    public class ChatValidator : AbstractValidator<NotificationModel>
    {
        public ChatValidator()
        {
            RuleSet("Insert", () =>
            {
                RuleFor(u => u.Content.Message).NotEmpty().WithMessage("请输入内容");
                Custom(u =>
                {
                    if (u.ReceiverToAdd == null)
                    {
                        return new ValidationFailure("NeedReceivers", "请选择接收人");
                    }
                    return null;
                });
            });

            RuleSet("Update", () =>
            {
            });

            RuleSet("Delete", () =>
            {
            });
        }
    }
}
